{% load i18n %}

<dt{% if milestone.closed %} class="closed"{% else %}{% if milestone.expired %} class="expired"{% endif %}{% endif %}>
    <h3><a href="{{ milestone.get_absolute_url }}">{{ milestone.title }}</a>{% if milestone.closed %} <span class="yes">({% trans "Closed" %})</span>{% endif %}</h3>
    <span class="actions">
        <ul>
            {% if perms.projects.change_milestone %}
            {% if not milestone.closed %}
            <li class="close"><a title="{% trans 'Close' %}" href="{% url milestone_close milestone.project.code milestone.code %}">{% trans 'Close' %}</a></li>
            {% else %}
            <li class="reopen"><a title="{% trans 'Reopen' %}" href="{% url milestone_reopen milestone.project.code milestone.code %}">{% trans 'Reopen' %}</a></li>
            {% endif %}
            {% endif %}
            {% if perms.projects.edit_milestone %}
            <li class="edit"><a title="{% trans "Edit" %}" href="{{ milestone.get_edit_url }}">{% trans "Edit" %}</a></li>
            {% endif %}
            {% if perms.projects.delete_milestone %}
            <li class="delete"><a title="{% trans "Delete" %}" href="{{ milestone.get_delete_url }}">{% trans "Delete" %}</a></li>
            {% endif %}
        </ul>
    </span>
</dt>
<dd>
    <p class="meta">
        <strong>{% trans "Deadline" %}:</strong>
        <span>
            {% if milestone.deadline %}
            {{ milestone.deadline }}
            {% if milestone.expired %}
            <span class="delay">({{ milestone.deadline|timesince }} {% trans "overdue" %})</span>
            {% else %}
            {% if not milestone.closed and milestone.deadline %}
            <span class="countdown">({{ milestone.deadline|timeuntil }})</span>
            {% endif %}
            {% endif %}
            {% else %}
            <span class="disabled">{% trans "empty" %}</span>
            {% endif %}
        </span>
        -
        <strong>{% trans "Tickets" %}:</strong>
        <span><a href="{% url milestone_tickets milestone.project.code milestone.code %}">{{ milestone.tickets.closed.count }}/{{ milestone.tickets.count }}</a></span>
        {% if milestone.closed %}
        -
        <strong>{% trans "Closed" %}:</strong>
        <span>{{ milestone.closed }}</span>
        {% endif %}
    </p>
    {% include "projects/milestone_progress.html" %}
    {{ milestone.description|safe }}
    {% if milestone.sub_milestones.all %}
    {% with milestone.sub_milestones.all as milestone_list %}
    <dl class="milestones">
        {% for milestone in milestone_list %}
        {% include 'projects/milestone.html' %}
        {% endfor %}
    </dl>
    {% endwith %}
    {% endif %}
</dd>
